package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {

    /**
     * 插入订单数据
     * @param order
     */
    void insert(Orders order);

    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    /**
     * 根据条件查询指定的超市支付的订单集合
     * @return
     */
    @Select("select *from orders where status=#{status} and order_time<#{time}")
    List<Orders> getByStatusAndOrdertimeLT(Integer status,LocalDateTime time);

    /**
     * 查询历史订单
     * @return
     */
    Page<Orders> page(OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 通过订单id查询订单
     * @param id
     * @return
     */

    @Select("select *from orders where id=#{id}")
    Orders getByOrderId(Long id);

    /**
     * top10
     * @param min
     * @param max
     * @return
     */
    List<GoodsSalesDTO> getSetmeal(LocalDateTime min, LocalDateTime max);

    Integer countByMap(Map map);


    Double sumByMap(Map map);
}
